package com.css.fxfzcpxx.modules.infoRetrieval.emergencyShelter.controller;

import com.css.fxfzcpxx.base.log.Log;
import com.css.fxfzcpxx.base.response.RestResponse;
import com.css.fxfzcpxx.modules.infoRetrieval.emergencyShelter.entity.JcEmergcyShelter;
import com.css.fxfzcpxx.modules.infoRetrieval.emergencyShelter.entity.SysDataVersion;
import com.css.fxfzcpxx.modules.infoRetrieval.emergencyShelter.param.JcEmergcyShelterParam;
import com.css.fxfzcpxx.modules.infoRetrieval.emergencyShelter.service.EmergencyShelterService;

import com.css.fxfzcpxx.modules.thematicMap.entity.AchManageEntity;
import com.css.fxfzcpxx.util.PlatformPageUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @Author: xzy
 * @CreateTime: 2023/04/08
 * @Description: 应急避难场所
 */
@Slf4j
@RestController
@RequestMapping("/emergencyShelter")
public class EmergencyShelterController {

    @Resource
    private EmergencyShelterService emergencyShelterService;


    /**
     * 最新版本号查询
     *
     * @return
     */
    @GetMapping("/getLatestVersion")
    public RestResponse getLatestVersion() {
        RestResponse restResponse = null;
        try {
            SysDataVersion sysDataVersion = emergencyShelterService.getLatestVersion();
            restResponse = RestResponse.succeed(sysDataVersion);
        } catch (Exception e) {
            String errormessage = "查询失败";
            log.error(errormessage, e);
            restResponse = RestResponse.fail(errormessage);
        }
        return restResponse;
    }

    /**
     * 分页列表
     *
     * @return
     */
    @GetMapping("/getPage")
    @Log(value="信息检索",type = "检索")
    public RestResponse getPage(JcEmergcyShelterParam param, HttpServletRequest request) {
        RestResponse restResponse = null;
        try {
            int curPage = Integer.parseInt(request.getParameter(PlatformPageUtils.CUR_PAGE));
            int pageSize = Integer.parseInt(request.getParameter(PlatformPageUtils.PAGE_SIZE));
            Map<String,Object> list = emergencyShelterService.getPage(param,curPage,pageSize);
            restResponse = RestResponse.succeed(list);
        } catch (Exception e) {
            String errormessage = "查询失败";
            log.error(errormessage, e);
            restResponse = RestResponse.fail(errormessage);
        }
        return restResponse;
    }

    /**
     * 分页列表
     *
     * @return
     */
   /* @PostMapping("/getPage")
    public RestResponse getPage(@RequestBody JcEmergcyShelterParam param) {
        RestResponse restResponse = null;
        try {
            *//*int curPage = Integer.parseInt(request.getParameter(PlatformPageUtils.CUR_PAGE));
            int pageSize = Integer.parseInt(request.getParameter(PlatformPageUtils.PAGE_SIZE));*//*
            Map<String,Object> list = emergencyShelterService.getPage(param);
            restResponse = RestResponse.succeed(list);
        } catch (Exception e) {
            String errormessage = "查询失败";
            log.error(errormessage, e);
            restResponse = RestResponse.fail(errormessage);
        }
        return restResponse;
    }*/

    /***
     * 工程查看
     * @param
     * @return
     */
    @GetMapping("findById")
    public RestResponse findById(String id) {
        RestResponse restResponse = null;
        try {
            JcEmergcyShelter jcEmergcyShelter = emergencyShelterService.findById(id);
            restResponse = RestResponse.succeed(jcEmergcyShelter);
        } catch (Exception e) {
            String errormessage = "查询失败";
            log.error(errormessage, e);
            restResponse = RestResponse.fail(errormessage);
        }
        return restResponse;
    }


}
